package com.example.ying.controller;

import com.example.ying.common.R;
import com.example.ying.model.request.CommentLikedRequest;
import com.example.ying.model.request.CommentRequest;
import com.example.ying.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class CommentController {
    @Autowired
    private CommentService commentService;


    // 提交评论
    @PostMapping("/comment/add")
    public R addComment(@RequestBody CommentRequest addCommentRequest) {
        return commentService.addComment(addCommentRequest);
    }

    // 删除评论
    @GetMapping("/comment/delete")
    public R deleteComment(@RequestParam Integer id) {
        return commentService.deleteComment(id);
    }

    // 获得指定电影 ID 的评论列表
    @GetMapping("/comment/detail")
    public R getCommentsBymovieId(@RequestParam Integer movieId) {
        return commentService.getCommentsBymovieId(movieId);
    }

    // 点赞
    @PostMapping("/comment/like")
    public R commentOfLike(@RequestBody CommentLikedRequest commentLikedRequest) {
        return commentService.updateCommentLiked(commentLikedRequest);
    }
}
